<?php
class ReportDoGetAction extends AdminAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'json';
	}

	public function execute()
	{
		$startDate		= $this->context->post('startDate');
		$endDate		= $this->context->post('endDate');
		$du				= C('DateUtil');
		if(!$du->isDate($startDate) || !$du->isDate($endDate) || $du->dateAdd('d',30,$startDate)<strtotime($endDate))
		{
			$this->code	= 400;
		}
		else
		{
			$sessionKey = C('LtCookie')->getCookie('sessionkey');
			$reportService	= new ReportService();
			$result			= $reportService->getTaoKeReportByPeriod($sessionKey,$startDate,$endDate);
			$result			= $reportService->addReports($result);
			if($result)
			{
				$this->code	= 200;
				$this->data['forward'] = C('LtUrl')->generate('Report', 'Index');
			}
			else
			{
				$this->code	= 500;
			}
		}
	}
}
